<?php
if ($this->count == 0) {
    echo "<table width='100%' border='0' cellspacing='5' cellpadding='2'>";
}
if ($this->count % 4 == 0) {
    echo "<tr style='min-height:120px;'>";
}
?>
<td class="view">
    <?php
//    $image = __FILE__."/../../../..".$data->brand_image_path;
//    $maxWidth = 120;
//    $imageWidth = 0;
//    $imagePath = $data->brand_image_path;
//    if (file_exists($image)) {
//        list($width) = getimagesize($image);
//        if ($width > $maxWidth){
//            $imageWidth = $maxWidth;
//        }else{
//            $imageWidth =  $width;
//        }
//    }else{
//       $imagePath = "/upload/images/logo/missing_logo.gif";
//       $imageWidth = $maxWidth;
//    }


    $imageURL = 'http://' . Yii::app()->request->getServerName() . Yii::app()->request->baseUrl . $data->brand_image_path;
    
    //หาวิธี Test Path image ไม่ได้หว่ะ ว่า exist รึป่าว
//    $test = @Getimagesize($imageURL);
//    echo $imageURL;
//    echo $test;
//    if(is_array($test)){
//        $imagePath = Yii::app()->request->baseUrl.$data->brand_image_path;
//    } else {
//        $imagePath = Yii::app()->request->baseUrl."/upload/images/logo/missing_logo.gif";
//    }
    $link = "<img src='" . $imageURL . "' class='brand_logo' border='0' width='120px'/>";
    echo CHtml::link($link, array('brandDetails/view', 'id' => $data->brand_id));
    ?>
</td>
<?php
    if ($this->count % 4 == 3) {
        echo "</tr>";
    }
    if ($this->count == $this->modelLength - 1) {
        echo "</table>";
    }
    $this->count = $this->count + 1;
?>

